package ar.com.gastos;

import objetos.Categoria;
import objetos.SubCategoria;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class Agregar_subcategoriaActivity extends Activity {

	Categoria cat;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.agregar_subcategoria);

	}

	public void pulsoBoton(View v) {
		EditText et = (EditText) findViewById(R.id.textoSubCategoria);

		if (!et.getText().toString().isEmpty()) {

			Intent data = new Intent();
			data.putExtra("nuevaSubCategoria", new SubCategoria(et.getText()
					.toString()));
			setResult(RESULT_OK, data);
			finish();

		} else {

			Toast.makeText(this, "El campo esta vacio", Toast.LENGTH_LONG)
					.show();

		}

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		if ((keyCode == KeyEvent.KEYCODE_BACK)) {
			setResult(RESULT_CANCELED);
			finish();

		}
		return false;

	}

}
